# -*- coding: utf-8 -*-

import web
import model
from config import setting

render = setting.render

class index:
    def GET(self):
        artists = model.get_artist_list((0, 10), 'asc')
        #artists = model.get_artist_info(544479)
        return render.VIndex(artists)

class add_member:
    def GET(self):
        return render.VAdd_member()

class collection:
    def GET(self, id):
        #return "Listing info about user: {0}".format(id)
        return render.VCollection()

class ajax_process:
    def POST(self):
        i = web.input()
        action = i.get('action', None)
        member_id = i.get('member_id', None)
        member_name = i.get('member_name', None)
        
        try:
            member_id = int(member_id)
        except ValueError:
            return '用户ID数据类型错误'
        
        if action == 'add_artist': #添加画师
            return model.add_artist(member_id, member_name)
            return True
        elif action == 'del_artist': #删除画师
            return model.del_artist(member_id)
            
        #return True